package org.moore.view;

import org.moore.utils.Data;

import javax.swing.*;
import java.awt.*;

import static org.moore.utils.Button.getjButton;


// 游戏界面关卡界面组件类
public class LevelLabel extends JLabel {
	// 定义低级按钮
    private final JButton lowerButton;
    // 定义中级按钮
    private final JButton middenButton;
    // 定义高级按钮
    private final JButton premiumButton;
    // 定义返回按钮
    private final JButton backButton;
    // 定义字体
    private final Font font = new Font("楷体", Font.BOLD, 50);

    public LevelLabel() {
        // 低级
        lowerButton = getjButton(null,null);
        lowerButton.setBounds(0,150,550,450);
        lowerButton.setActionCommand("lower");
        this.add(lowerButton);
        // 中级
        middenButton = getjButton(null,null);
        middenButton.setBounds(350,150,550,450);
        middenButton.setActionCommand("midden");
        this.add(middenButton);
        // 高级
        premiumButton = getjButton(null,null);
        premiumButton.setBounds(750,160,550,400);
        premiumButton.setActionCommand("premium");
        this.add(premiumButton);
        // 返回
        backButton = getjButton(null,Data.FONT);
        backButton.setText("返回");
        backButton.setForeground(Color.BLACK);
        backButton.setBounds(900,540,100,100);
        backButton.setActionCommand("back");
        this.add(backButton);
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        // 使用g2d绘制以修复抗锯齿
        Graphics2D g2d = (Graphics2D) g;
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        // 绘制背景图片
        g2d.drawImage(Data.LEVEL_BACKGROUND, 0, 0, this.getWidth(), this.getHeight(), null);
        // 绘制标题
        g2d.drawImage(Data.LEVEL_TITLE,450,50,1500,100,null);
        // 设置字体
        g2d.setFont(font);
        // 绘制低级按钮背景
        g2d.drawImage(Data.LOW_LEVEL,-50,150,550,350,null);
        // 绘制文字
        g2d.drawString("低级           中级           高级",155,520);
        // 绘制中级按钮背景
        g2d.drawImage(Data.MID_LEVEL,350,150,550,350,null);
        // 绘制高级按钮背景
        g2d.drawImage(Data.PRE_LEVEL,750,160,550,330,null);
    }

    public JButton getLowerButton() {
        return lowerButton;
    }

    public JButton getMiddenButton() {
        return middenButton;
    }

    public JButton getPremiumButton() {
        return premiumButton;
    }

    public JButton getBackButton() {
        return backButton;
    }

}
